/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.front.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;

import com.thinkgem.jeesite.common.persistence.TreeEntity;

/**
 * 区域管理Entity
 * @author 朱俊吉
 * @version 2017-11-27
 */
public class Region extends TreeEntity<Region> {
	
	private static final long serialVersionUID = 1L;
	private Region parent;		// 父编号
	private String name;		// 名称
	private String regionType;		// 级别
	private String parentIds;		// 所有父编号
	private String agencyId;		// 所属国家
	private Integer sort;		// 排序
	private Date creaeDate;		// 创建时间
	private String remarkes;		// 备注信息
	
	public Region() {
		super();
	}

	public Region(String id){
		super(id);
	}

	@JsonBackReference
	@NotNull(message="父编号不能为空")
	public Region getParent() {
		return parent;
	}

	public void setParent(Region parent) {
		this.parent = parent;
	}
	
	@Length(min=1, max=120, message="名称长度必须介于 1 和 120 之间")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Length(min=1, max=1, message="级别长度必须介于 1 和 1 之间")
	public String getRegionType() {
		return regionType;
	}

	public void setRegionType(String regionType) {
		this.regionType = regionType;
	}
	
	@Length(min=0, max=2000, message="所有父编号长度必须介于 0 和 2000 之间")
	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}
	
	@Length(min=1, max=5, message="所属国家长度必须介于 1 和 5 之间")
	public String getAgencyId() {
		return agencyId;
	}

	public void setAgencyId(String agencyId) {
		this.agencyId = agencyId;
	}
	
	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getCreaeDate() {
		return creaeDate;
	}

	public void setCreaeDate(Date creaeDate) {
		this.creaeDate = creaeDate;
	}
	
	@Length(min=0, max=255, message="备注信息长度必须介于 0 和 255 之间")
	public String getRemarkes() {
		return remarkes;
	}

	public void setRemarkes(String remarkes) {
		this.remarkes = remarkes;
	}
	
	public String getParentId() {
		return parent != null && parent.getId() != null ? parent.getId() : "0";
	}
}